#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    vector<int> resultsArray(vector<int>& nums, int k) {
        int conse = 1, n = nums.size();
        if (k == 1) return nums;
        vector<int> res;
        for (int i = 1; i < n; i++)
        {
            if (nums[i] - 1 == nums[i - 1]) conse++;
            else conse = 1;
            if (i >= k - 1)
            {
                if (conse >= k) res.push_back(nums[i]);
                else res.push_back(-1);
            }
        }
        return res;
    }
};